home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-10-25 | 6.2 KB | 206 lines | [TEXT/MPS ] |
- {Copyright © 1989 by Apple Computer, Inc. All rights reserved.}
-
- UNIT UIconEdit;
-
-
- INTERFACE
-
-
- USES
- { • MacApp }
- UMacApp,
-
- { • Toolbox }
- ToolUtils;
-
-
- CONST kSignature = 'ICED';
- kFileType = 'IDOC';
-
-
- TYPE
- TIconApplication = OBJECT(TApplication)
-
- PROCEDURE TIconApplication.IIconApplication(iconFileType: OSType);
- {Initializes the application and globals.}
-
- FUNCTION TIconApplication.DoMakeDocument(itsCmdNumber: CmdNumber): TDocument; OVERRIDE;
- { Creates a document of type TIconDocument and returns a reference to it.}
-
- END;
-
-
- TIconDocument = OBJECT(TDocument)
-
- fIconBitMap: TIconBitMap; { The document’s icon object. }
-
- PROCEDURE TIconDocument.IIconDocument;
- { Initializes the document. }
-
- PROCEDURE TIconDocument.Free; OVERRIDE;
- { Frees allocated memory when the document is closed. }
-
- PROCEDURE TIconDocument.DoInitialState; OVERRIDE;
- { Sets the document's data to represent a "new" document. }
-
- PROCEDURE TIconDocument.DoMakeViews (forPrinting: BOOLEAN); OVERRIDE;
- { Creates the window and view objects when an icon document is opened.}
-
- PROCEDURE TIconDocument.RedrawViews;
- { Causes all views representing this document to be redrawn. }
-
- PROCEDURE TIconDocument.DoSetupMenus; OVERRIDE;
- { Sets the state of the menu items to which this class responds. }
-
- FUNCTION TIconDocument.DoMenuCommand (aCmdNumber: CmdNumber): TCommand; OVERRIDE;
- { Handles menu items specific to this class. }
-
- PROCEDURE TIconDocument.InvertIcon;
- { Inverts the bits of this document's icon and redraw its views. }
-
- PROCEDURE TIconDocument.Fields (PROCEDURE DoToField (fieldName: Str255;
- fieldAddr: Ptr;
- fieldType: INTEGER)); OVERRIDE;
-
- END;
-
-
-
-
- TIconView = OBJECT(TView)
-
- fMagnification: INTEGER; { No. of times to magnify the icon. }
- fIconDocument: TIconDocument; { Reference to the view's icon document.}
-
- PROCEDURE TIconView.IRes (itsDocument: TDocument; itsSuperView: TView;
- VAR itsParams: Ptr); OVERRIDE;
- { Initializes the view from a resource template. }
-
- PROCEDURE TIconView.CalcMinSize (VAR minSize: VPoint); OVERRIDE;
- { Returns the view's minimum size. }
-
- PROCEDURE TIconView.Draw (area: Rect); OVERRIDE;
- { Draws this view. }
-
- PROCEDURE TIconView.DrawBit (theBit: Point; turnBitOn: BOOLEAN);
- { Draws the given bit to the given state. }
-
- PROCEDURE TIconView.DoSetupMenus; OVERRIDE;
- { Sets the state of the menu items to which this class responds. }
-
- FUNCTION TIconView.DoMenuCommand (aCmdNumber: CmdNumber): TCommand; OVERRIDE;
- { Handles menu items specific to this class. }
-
- PROCEDURE TIconView.SetMagnification (magnification: INTEGER);
- { Sets the view's magnification. }
-
- FUNCTION TIconView.DoMouseCommand (VAR theMouse: Point; VAR info: EventInfo;
- VAR hysteresis: Point): TCommand; OVERRIDE;
- { Handle mouse clicks in this view. }
-
- FUNCTION TIconView.PointToBit (thePoint: Point; VAR iconBit: Point): BOOLEAN;
- { Converts the given mouse point to an icon bit. }
-
- PROCEDURE TIconView.Fields (PROCEDURE DoToField (fieldName: Str255;
- fieldAddr: Ptr;
- fieldType: INTEGER)); OVERRIDE;
-
- END;
-
-
-
- TInvertCommand = OBJECT(TCommand)
-
- fIconDocument: TIconDocument; { The document affected by this command.}
-
- PROCEDURE TInvertCommand.IInvertCommand (itsIconDocument: TIconDocument);
- { Initializes this command, associates it with the given document. }
-
- PROCEDURE TInvertCommand.DoIt; OVERRIDE;
- { Implements the command's action by calling the document's Invert method. }
-
- PROCEDURE TInvertCommand.RedoIt; OVERRIDE;
- { Redoes the command's action by calling the document's Invert method. }
-
- PROCEDURE TInvertCommand.UndoIt; OVERRIDE;
- { Undoes the command's action by calling the document's Invert method. }
-
- END;
-
-
-
- TDrawCommand = OBJECT(TCommand)
-
- fIconDocument: TIconDocument; { The document affected by this command.}
- fIconView: TIconView; { The view in which this command draws. }
- fIconBitMap: TIconBitMap; { The icon in which drawing takes place.}
- fTurnBitsOn: BOOLEAN; { Whether to draw bits black or white. }
-
- PROCEDURE TDrawCommand.IDrawCommand (itsIconView: TIconView);
- { Initializes the command and associates it with a view. }
-
- PROCEDURE TDrawCommand.TrackConstrain(anchorPoint, previousPoint: VPoint;
- VAR nextPoint: VPoint); OVERRIDE;
- { Constrains the mouse to be within the icon in the edit view by
- factoring out the margins. }
-
- PROCEDURE TDrawCommand.TrackFeedback(anchorPoint, nextPoint: VPoint;
- turnItOn, mouseDidMove: BOOLEAN); OVERRIDE;
- { Overridden to avoid standard feedback. }
-
- FUNCTION TDrawCommand.TrackMouse(aTrackPhase: TrackPhase;
- VAR anchorPoint, previousPoint, nextPoint: VPoint;
- mouseDidMove: BOOLEAN): TCommand; OVERRIDE;
- { Tracks the mouse. }
- END;
-
-
-
- TIconBitMap = OBJECT(TObject)
-
- fDataHandle: Handle; { Handle to the icon's bit map. }
-
- PROCEDURE TIconBitMap.IIconBitMap;
- { Initialize the IconBitMap object and allocate space for its data. }
-
- PROCEDURE TIconBitMap.Free; OVERRIDE;
- { Free the icon's bit map. }
-
- PROCEDURE TIconBitMap.SetIconBitMap(theBitMap : Handle);
- { Set the contents of the icon bit map to the new bit map. }
-
- PROCEDURE TIconBitMap.Clear;
- { Clear the icon map by setting its bits to zero. }
-
- PROCEDURE TIconBitMap.Invert;
- { Invert the icon's bit map. }
-
- PROCEDURE TIconBitMap.IconBitToWordBit (iconBit: Point; VAR word, bit: INTEGER);
- { Convert icon bit numbers to the corresponding word and bit number. }
-
- FUNCTION TIconBitMap.GetBit(iconBit: Point): BOOLEAN;
- { Return the state of the given bit. }
-
- PROCEDURE TIconBitMap.SetBit(iconBit: Point; turnBitOn: BOOLEAN);
- { Set the state of the given bit as indicated. }
-
- PROCEDURE TIconBitMap.Draw (area: Rect);
- { Draw the icon's bit map. }
-
- FUNCTION TIconBitMap.Copy: TIconBitMap;
- { Create a new icon object which is a copy of itself. }
-
- PROCEDURE TIconBitMap.CopyDataTo (anIcon: TIconBitMap);
- { Copy icon data to an existing icon object. }
-
- PROCEDURE TIconBitMap.Fields (PROCEDURE DoToField (fieldName: Str255;
- fieldAddr: Ptr;
- fieldType: INTEGER)); OVERRIDE;
- END;
-
-
- IMPLEMENTATION
-
- {$I UIconEdit.inc1.p}
-
- END.